﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hidistro.UI.Common.Controls;
using System.Web.UI.WebControls;
using Hidistro.SaleSystem.Catalog;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Xml;
using Hidistro.Entities;
using Hidistro.Entities.Commodities;
using System.Collections;
using Hidistro.Core;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class js_Common_SubCategoriesURL : WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(this.RendHtml());
        }

        public string RendHtml()
        {

            StringBuilder builder = new StringBuilder();

            List<CategoryInfo> list = CategoryBrowser.GetMaxSubCategories(SubjectId, 0x3e8) as List<CategoryInfo>;
            foreach (CategoryInfo ca in list)
            {
                builder.AppendFormat("<a href=\"{0}\" >", Globals.GetSiteUrls().SubCategory(Convert.ToInt32(ca.CategoryId), ca.RewriteName, ca.ParentRewriteName)).AppendLine();
                builder.AppendFormat("" + ca.Name).AppendLine();
                builder.AppendFormat("</a>").AppendLine();
            }

            return builder.ToString();
        }

        public int SubjectId { get; set; }
    }
}
